/*
day128
2020.1.3
*/
#include<iostream>
#include<vector>
using namespace std;


class Solution1 {
public:
    int minSubArrayLen(int s, vector<int>& nums) {
        int ans=INT_MAX;
        int sum=0;
        int size=nums.size();
        int left;
        int tem; 
        for(int i=0;i<size;i++)
        {
        	sum += nums[i];

        	while(sum >= s)
        	{
        		tem=i-left+1;
        		ans = ans <= tem ? ans : tem;

        		sum-=nums[left++];
			}
		}
		
		return ans<INT_MAX ? ans : 0;
    }
};






int main()
{
	int target=4;
	vector<int> nums={1,4,4};
	Solution1 s;
	cout<<s.minSubArrayLen(target,nums)<<endl;
	return 0;
}
